package br.com.goldentrade.util.table;

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;

public class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {

    	public MultiLineCellRenderer() {
    		setEditable(false);
    		setLineWrap(true);
    		setWrapStyleWord(true);
    		setBorder(BorderFactory.createEtchedBorder());
    		setRows(3);
    		this.setPreferredSize(new Dimension(50, 50));
    	}

    	public Component getTableCellRendererComponent(JTable table,Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    		
    		if (value instanceof String) {
    			setText((String)value);
    			// set the table's row height, if necessary
    			//updateRowHeight(row,getPreferredSize().height);
    		}
    		else
    			setText("");

    		setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    		setBackground(UIManager.getColor("TableHeader.background"));
    		setForeground(UIManager.getColor("TableHeader.foreground"));
    		setFont(UIManager.getFont("TableHeader.font"));

    		return this;
    	}
    } 